<?php
if(!defined('IN_WEB')) {
	exit('Access Denied');
}

class UserController extends Controller{
	function __construct(){
		parent::__construct();
		$this->userAction = new UserAction();
	}
    //查看用户
    function  items(){
        $userList = $this->userAction->viewUser();
        $this->smarty->assign('userList', $userList);
        $this->smarty->display('admin/user/viewUser.tpl');
    }
	//添加用户
	function add(){
		if($_POST['submit']){
			$result = $this->userAction->addUser($_POST);
			switch($result){
				case 1:
					$msg = '添加成功';
					break;
				case -1:
					$msg = '添加失败';
					break;
				case -2:
					$msg = '已存在的用户名';
					break;
				default:
					$msg = '未知错误';
			}
			$this->smarty->assign('msg', $msg);
		}
		$this->smarty->display('admin/user/add.tpl');
	}
}